var layer;
var $;
var element;
var form;
var laydate;
var table;
var upload;
layui.use(['element','layer','laydate','form','table','upload'], function(){
    layer = layui.layer;
    $ = layui.jquery;
    element = layui.element;
    form = layui.form;
    laydate = layui.laydate;
    table = layui.table;
    upload = layui.upload;
    load();
})
function load(){
    var avatarUrl = $("input[name=avatarUrl]").val();
    var photoImg = $("input[name=photoImg]").val();
    $(".img_title").attr("src",avatarUrl+photoImg);
    //点击上传图片
    $("#upload_btn").on("click",function(){
        $("#imgbut").click();
    });
    //图片上传
    var uploadInst = upload.render({
        elem: '#imgbut',
        url: '/personnel/updImg',//改成您自己的上传接口,
        accept:'images',
        size: 5000, //限制文件大小单位 KB
        before: function (obj) {
            var userId = $("input[name=userId]").val();
            var developmentId = 0;
            this.data={'developmentId':developmentId,'userId':userId}
            //预读本地文件示例
            obj.preview(function (index, file, result) {
                $('.img_title').attr('src', result); //图片链接(base64)
            });
        }, done: function (res) {
            layer.msg('更换成功', {icon: 1});
            parent.selIndexUserTab();
            //上传成功的一些操作
        }, error: function () {
            //失败
            layer.msg('更换失败', {icon: 2});
        }
    });
}
